home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 55
/
MOBICLIC 55.ISO
/
DATA
/
ARRIBA
/
SWF_ARRIBA
/
arri01.swf
/
scripts
/
DefineSprite_76
/
frame_1
/
DoAction.as
Wrap
Text File
|
2003-06-02
|
5KB
|
233 lines
function pause(pPause)
{
if(pPause)
{
gotoAndStop(4);
}
else
{
gotoAndStop(9);
}
}
function init(pSide)
{
if(pSide == null)
{
pSide = 0;
}
_side = pSide;
mcGraph.mcSide.gotoAndStop(_side + 1);
mcGraph.mcSide._rotation = - _rotation;
vGameMC = _parent.mcGame;
vGameMC.registerPlayer(this,_side);
mcControl.gotoAndStop("Void");
if(vGameMC.vControlTab[_side] == null)
{
this.getHighLight(true);
if(_side == _parent._startSide)
{
hasBall(1);
vGameMC._targetMC = this;
}
else
{
hasBall(0);
}
}
if(0 < pSide)
{
call("MouseBot");
var lFactor = _parent._factor;
}
else
{
call("Mouse");
var lFactor = 1;
}
vSpeed = lFactor * _parent.uSpeed;
vSpeedwBall = lFactor * _parent.uSpeedwBall;
_X = _X + _parent.uPlacement * (Math.random() * 2 - 1);
_Y = _Y + _parent.uPlacement * (Math.random() * 2 - 1);
vXMin = _parent.mcBounds._x;
vYMin = _parent.mcBounds._y;
vXMax = _parent.mcBounds._x + _parent.mcBounds._width;
vYMax = _parent.mcBounds._y + _parent.mcBounds._height;
checkBounds();
_radius = 20 * _xscale / 100;
vDeg2Rad = 0.017453292519943295;
vCos = Math.cos(_rotation * vDeg2Rad);
vSin = Math.sin(_rotation * vDeg2Rad);
vLaunchDist = 24;
vLaunchSpeed = _parent.uShoot;
vDropSpeed = _parent.uDrop;
}
function getHighLight(pControl)
{
var lOld;
if(pControl)
{
lOld = vGameMC.vControlTab[this._side];
lOld._control = 0;
lOld.mcControl.gotoAndStop("Void");
vGameMC.vControlTab[_side] = this;
_control = 1;
this.mcControl.gotoAndPlay("Control");
}
else
{
lOld = vGameMC.vLightTab[this._side];
if(!lOld._control)
{
lOld.mcControl.gotoAndStop("Void");
}
vGameMC.vLightTab[_side] = this;
if(!_control)
{
mcControl.gotoAndStop("Light");
}
}
}
function checkBounds()
{
if(_X < vXMin)
{
_X = vXMin;
}
else if(vXmax < _X)
{
_X = vXMax;
}
if(_Y < vYMin)
{
_Y = vYMin;
}
else if(vYmax < _Y)
{
_Y = vYMax;
}
}
function hasBall(pHasBall)
{
_hasBall = pHasBall;
if(pHasBall)
{
mcGraph.gotoAndStop("Ball");
}
else
{
mcGraph.gotoAndStop(1);
}
}
function loop()
{
if(_stun)
{
_stun--;
if(_stun == 0)
{
mcGraph.mcEyes.gotoAndStop(1);
}
}
if(_control)
{
mcGraph.mcSide._rotation = - _rotation;
if(_hasBall)
{
mcGraph.mcBall._rotation = - _rotation;
if(0 < _shield)
{
_shield--;
}
}
getLoop();
getGoal();
var lX = vGoalX - _X;
var lY = vGoalY - _Y;
var lDist2 = lX * lX + lY * lY;
if(1 < lDist2)
{
var lAngle = Math.atan2(lY,lX);
_rotation = lAngle / vDeg2Rad;
vCos = Math.cos(lAngle);
vSin = Math.sin(lAngle);
}
if(lDist2 >= _radius * _radius)
{
if(_hasBall)
{
_speedX = vSpeedwBall * vCos;
_speedY = vSpeedwBall * vSin;
}
else
{
_speedX = vSpeed * vCos;
_speedY = vSpeed * vSin;
}
_X = _X + _speedX;
_Y = _Y + _speedY;
checkBounds();
}
var lColMC = vGameMC.getCollidingPlayer(this,null,true);
var lTargetPlayer = vGameMC.getNearestPlayer(vGoalX,vGoalY,this._side);
var lShoot = getShoot();
if(lShoot)
{
if(_hasBall and !_stun)
{
var lX = _X + vCos * vLaunchDist;
var lY = _Y + vSin * vLaunchDist;
var lSpeedX = vCos * vLaunchSpeed;
var lSpeedY = vSin * vLaunchSpeed;
vGameMC.launchBall(lX,lY,lSpeedX,lSpeedY);
hasBall(false);
}
if(lTargetPlayer != null)
{
lTargetPlayer.getHighLight(true);
}
}
else if(lTargetPlayer != this)
{
lTargetPlayer.getHighLight(false);
}
mcGraph.mcSide._rotation = - _rotation;
if(_hasBall)
{
mcGraph.mcBall._rotation = - _rotation;
}
}
}
function dropBall(pMC)
{
if(0 < pMC._stun)
{
return null;
}
getStun();
var lX = _X - pMC._x;
var lY = _Y - pMC._y;
var lNorm = - Math.sqrt(lX * lX + lY * lY);
lX /= lNorm;
lY /= lNorm;
var lSpeedX = lX * vDropSpeed;
var lSpeedY = lY * vDropSpeed;
lX = _X + lX * vLaunchDist;
lY = _Y + lY * vLaunchDist;
vGameMC.launchBall(lX,lY,lSpeedX,lSpeedY);
hasBall(false);
}
function getStun()
{
_stun = _parent.uStun;
mcGraph.mcEyes.gotoAndStop(2);
}
if(_name.substr(0,1) == "r")
{
init(1);
}
else
{
init(0);
}
pause(true);